/*
* 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
*/
package com.shatteredpixel.shatteredpixeldungeon.items.wands;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.DeathRay;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PurpleParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Death;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class WandOfDisintegration extends Wand {
{
name = "Wand of Disintegration";
image = ItemSpriteSheet.WAND_DISINTEGRATION;
collisionProperties = Ballistica.STOP_TERRAIN;
}
@Override
protected void onZap( Ballistica beam ) {
boolean terrainAffected = false;
int level = level();
int maxDistance = Math.min(distance(), beam.dist);
ArrayList chars = new ArrayList();
for (int c : beam.subPath(1, maxDistance)) {
Char ch;
if ((ch = Actor.findChar( c )) != null) {
chars.add( ch );
}
int terr = Dungeon.level.map[c];
if (terr == Terrain.DOOR || terr == Terrain.BARRICADE) {
Level.set( c, Terrain.EMBERS );
GameScene.updateMap( c );
terrainAffected = true;
} else if (terr == Terrain.HIGH_GRASS) {
Level.set( c, Terrain.GRASS );
GameScene.updateMap( c );
terrainAffected = true;
}
CellEmitter.center( c ).burst( PurpleParticle.BURST, Random.IntRange( 1, 2 ) );
}
if (terrainAffected) {
Dungeon.observe();
}
int lvl = level + chars.size();
int dmgMin = lvl;
int dmgMax = 8 + lvl * lvl / 3;
for (Char ch : chars) {
ch.damage( Random.NormalIntRange( dmgMin, dmgMax ), this );
ch.sprite.centerEmitter().burst( PurpleParticle.BURST, Random.IntRange( 1, 2 ) );
ch.sprite.flash();
}
}
@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
//less likely Grim proc
if (Random.Int(10) == 0)
new Death().proc( staff, attacker, defender, damage);
}
private int distance() {
return level() + 4;
}
@Override
protected void fx( Ballistica beam, Callback callback ) {
int cell = beam.path.get(Math.min(beam.dist, distance()));
curUser.sprite.parent.add( new DeathRay( curUser.sprite.center(), DungeonTilemap.tileCenterToWorld( cell ) ) );
callback.call();
}
@Override
public String desc() {
return
"This wand emits a beam of destructive energy, which pierces all creatures in its way. " +
"The more targets it hits, the more damage it inflicts to each of them.";
}
}