V0.1.0 Partial Commit

changed package and application names to differentiate from main PD
release
This commit is contained in:
Evan Debenham
2014-08-03 14:46:22 -04:00
parent 65dd9c2dc0
commit aed303672a
474 changed files with 3468 additions and 3458 deletions
@@ -0,0 +1,475 @@
/*
* 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 java.util.ArrayList;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
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.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfPower.Power;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public abstract class Wand extends KindOfWeapon {
public static final String AC_ZAP = "ZAP";
private static final String TXT_WOOD = "This thin %s wand is warm to the touch. Who knows what it will do when used?";
private static final String TXT_DAMAGE = "When this wand is used as a melee weapon, its average damage is %d points per hit.";
private static final String TXT_WEAPON = "You can use this wand as a melee weapon.";
private static final String TXT_FIZZLES = "your wand fizzles; it must be out of charges for now";
private static final String TXT_SELF_TARGET = "You can't target yourself";
private static final float TIME_TO_ZAP = 1f;
public int maxCharges = initialCharges();
public int curCharges = maxCharges;
protected Charger charger;
private boolean curChargeKnown = false;
protected boolean hitChars = true;
private static final Class<?>[] wands = {
WandOfTeleportation.class,
WandOfSlowness.class,
WandOfFirebolt.class,
WandOfPoison.class,
WandOfRegrowth.class,
WandOfBlink.class,
WandOfLightning.class,
WandOfAmok.class,
WandOfTelekinesis.class,
WandOfFlock.class,
WandOfDisintegration.class,
WandOfAvalanche.class
};
private static final String[] woods =
{"holly", "yew", "ebony", "cherry", "teak", "rowan", "willow", "mahogany", "bamboo", "purpleheart", "oak", "birch"};
private static final Integer[] images = {
ItemSpriteSheet.WAND_HOLLY,
ItemSpriteSheet.WAND_YEW,
ItemSpriteSheet.WAND_EBONY,
ItemSpriteSheet.WAND_CHERRY,
ItemSpriteSheet.WAND_TEAK,
ItemSpriteSheet.WAND_ROWAN,
ItemSpriteSheet.WAND_WILLOW,
ItemSpriteSheet.WAND_MAHOGANY,
ItemSpriteSheet.WAND_BAMBOO,
ItemSpriteSheet.WAND_PURPLEHEART,
ItemSpriteSheet.WAND_OAK,
ItemSpriteSheet.WAND_BIRCH};
private static ItemStatusHandler<Wand> handler;
private String wood;
{
defaultAction = AC_ZAP;
}
@SuppressWarnings("unchecked")
public static void initWoods() {
handler = new ItemStatusHandler<Wand>( (Class<? extends Wand>[])wands, woods, images );
}
public static void save( Bundle bundle ) {
handler.save( bundle );
}
@SuppressWarnings("unchecked")
public static void restore( Bundle bundle ) {
handler = new ItemStatusHandler<Wand>( (Class<? extends Wand>[])wands, woods, images, bundle );
}
public Wand() {
super();
calculateDamage();
try {
image = handler.image( this );
wood = handler.label( this );
} catch (Exception e) {
// Wand of Magic Missile
}
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (curCharges > 0 || !curChargeKnown) {
actions.add( AC_ZAP );
}
if (hero.heroClass != HeroClass.MAGE) {
actions.remove( AC_EQUIP );
actions.remove( AC_UNEQUIP );
}
return actions;
}
@Override
public boolean doUnequip( Hero hero, boolean collect ) {
charger.detach();
return super.doUnequip(hero, collect);
}
@Override
public void activate( Hero hero ) {
charge( hero );
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_ZAP )) {
curUser = hero;
curItem = this;
GameScene.selectCell( zapper );
} else {
super.execute( hero, action );
}
}
protected abstract void onZap( int cell );
@Override
public boolean collect( Bag container ) {
if (super.collect( container )) {
if (container.owner != null) {
charge( container.owner );
}
return true;
} else {
return false;
}
};
public void charge( Char owner ) {
(charger = new Charger()).attachTo( owner );
}
@Override
public Item detach( Bag container ) {
stopCharging();
return super.detach( container );
}
public void stopCharging() {
if (charger != null) {
charger.detach();
charger = null;
}
}
public int level() {
if (charger != null) {
Power power = charger.target.buff( Power.class );
return power == null ? level : Math.max( level + power.level, 0 );
} else {
return level;
}
}
protected boolean isKnown() {
return handler.isKnown( this );
}
public void setKnown() {
if (!isKnown()) {
handler.know( this );
}
Badges.validateAllWandsIdentified();
}
@Override
public Item identify() {
setKnown();
curChargeKnown = true;
super.identify();
updateQuickslot();
return this;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder( super.toString() );
String status = status();
if (status != null) {
sb.append( " (" + status + ")" );
}
return sb.toString();
}
@Override
public String name() {
return isKnown() ? name : wood + " wand";
}
@Override
public String info() {
StringBuilder info = new StringBuilder( isKnown() ? desc() : String.format( TXT_WOOD, wood ) );
if (Dungeon.hero.heroClass == HeroClass.MAGE) {
info.append( "\n\n" );
if (levelKnown) {
info.append( String.format( TXT_DAMAGE, MIN + (MAX - MIN) / 2 ) );
} else {
info.append( String.format( TXT_WEAPON ) );
}
}
return info.toString();
}
@Override
public boolean isIdentified() {
return super.isIdentified() && isKnown() && curChargeKnown;
}
@Override
public String status() {
if (levelKnown) {
return (curChargeKnown ? curCharges : "?") + "/" + maxCharges;
} else {
return null;
}
}
@Override
public Item upgrade() {
super.upgrade();
updateLevel();
curCharges = Math.min( curCharges + 1, maxCharges );
updateQuickslot();
return this;
}
@Override
public Item degrade() {
super.degrade();
updateLevel();
updateQuickslot();
return this;
}
protected void updateLevel() {
maxCharges = Math.min( initialCharges() + level, 9 );
curCharges = Math.min( curCharges, maxCharges );
calculateDamage();
}
protected int initialCharges() {
return 2;
}
private void calculateDamage() {
int tier = 1 + level / 3;
MIN = tier;
MAX = (tier * tier - tier + 10) / 2 + level;
}
protected void fx( int cell, Callback callback ) {
MagicMissile.blueLight( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
protected void wandUsed() {
curCharges--;
updateQuickslot();
curUser.spendAndNext( TIME_TO_ZAP );
}
@Override
public Item random() {
if (Random.Float() < 0.5f) {
upgrade();
if (Random.Float() < 0.15f) {
upgrade();
}
}
return this;
}
public static boolean allKnown() {
return handler.known().size() == wands.length;
}
@Override
public int price() {
int price = 50;
if (cursed && cursedKnown) {
price /= 2;
}
if (levelKnown) {
if (level > 0) {
price *= (level + 1);
} else if (level < 0) {
price /= (1 - level);
}
}
if (price < 1) {
price = 1;
}
return price;
}
private static final String MAX_CHARGES = "maxCharges";
private static final String CUR_CHARGES = "curCharges";
private static final String CUR_CHARGE_KNOWN = "curChargeKnown";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( MAX_CHARGES, maxCharges );
bundle.put( CUR_CHARGES, curCharges );
bundle.put( CUR_CHARGE_KNOWN, curChargeKnown );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
maxCharges = bundle.getInt( MAX_CHARGES );
curCharges = bundle.getInt( CUR_CHARGES );
curChargeKnown = bundle.getBoolean( CUR_CHARGE_KNOWN );
}
protected static CellSelector.Listener zapper = new CellSelector.Listener() {
@Override
public void onSelect( Integer target ) {
if (target != null) {
if (target == curUser.pos) {
GLog.i( TXT_SELF_TARGET );
return;
}
final Wand curWand = (Wand)Wand.curItem;
curWand.setKnown();
final int cell = Ballistica.cast( curUser.pos, target, true, curWand.hitChars );
curUser.sprite.zap( cell );
QuickSlot.target( curItem, Actor.findChar( cell ) );
if (curWand.curCharges > 0) {
curUser.busy();
curWand.fx( cell, new Callback() {
@Override
public void call() {
curWand.onZap( cell );
curWand.wandUsed();
}
} );
Invisibility.dispel();
} else {
curUser.spendAndNext( TIME_TO_ZAP );
GLog.w( TXT_FIZZLES );
curWand.levelKnown = true;
curWand.updateQuickslot();
}
}
}
@Override
public String prompt() {
return "Choose direction to zap";
}
};
protected class Charger extends Buff {
private static final float TIME_TO_CHARGE = 40f;
@Override
public boolean attachTo( Char target ) {
super.attachTo( target );
delay();
return true;
}
@Override
public boolean act() {
if (curCharges < maxCharges) {
curCharges++;
updateQuickslot();
}
delay();
return true;
}
protected void delay() {
float time2charge = ((Hero)target).heroClass == HeroClass.MAGE ?
TIME_TO_CHARGE / (float)Math.sqrt( 1 + level ) :
TIME_TO_CHARGE;
spend( time2charge );
}
}
}
@@ -0,0 +1,61 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Amok;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
public class WandOfAmok extends Wand {
{
name = "Wand of Amok";
}
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch != null) {
Buff.affect( ch, Amok.class, 3f + level() );
} else {
GLog.i( "nothing happened" );
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.purpleLight( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"The purple light from this wand will make the target run amok " +
"attacking random creatures in its vicinity.";
}
}
@@ -0,0 +1,100 @@
/*
* 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.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";
hitChars = false;
}
@Override
protected void onZap( int cell ) {
Sample.INSTANCE.play( Assets.SND_ROCKS );
int level = level();
Ballistica.distance = Math.min( Ballistica.distance, 8 + level );
int size = 1 + level / 3;
PathFinder.buildDistanceMap( cell, 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.WAND, name, Dungeon.depth ) );
GLog.n( "You killed yourself with your own Wand of Avalanche..." );
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.earth( curUser.sprite.parent, curUser.pos, cell, 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.";
}
}
@@ -0,0 +1,82 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.watabou.noosa.tweeners.AlphaTweener;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.watabou.utils.Callback;
public class WandOfBlink extends Wand {
{
name = "Wand of Blink";
}
@Override
protected void onZap( int cell ) {
int level = level();
if (Ballistica.distance > level + 4) {
cell = Ballistica.trace[level + 3];
} else if (Actor.findChar( cell ) != null && Ballistica.distance > 1) {
cell = Ballistica.trace[Ballistica.distance - 2];
}
curUser.sprite.visible = true;
appear( Dungeon.hero, cell );
Dungeon.observe();
}
@Override
protected void fx( int cell, Callback callback ) {
MagicMissile.whiteLight( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
curUser.sprite.visible = false;
}
public static void appear( Char ch, int pos ) {
ch.sprite.interruptMotion();
ch.move( pos );
ch.sprite.place( pos );
if (ch.invisible == 0) {
ch.sprite.alpha( 0 );
ch.sprite.parent.add( new AlphaTweener( ch.sprite, 1, 0.4f ) );
}
ch.sprite.emitter().start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
Sample.INSTANCE.play( Assets.SND_TELEPORT );
}
@Override
public String desc() {
return
"This wand will allow you to teleport in the chosen direction. " +
"Creatures and inanimate obstructions will block the teleportation.";
}
}
@@ -0,0 +1,114 @@
/*
* 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 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.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class WandOfDisintegration extends Wand {
{
name = "Wand of Disintegration";
hitChars = false;
}
@Override
protected void onZap( int cell ) {
boolean terrainAffected = false;
int level = level();
int maxDistance = distance();
Ballistica.distance = Math.min( Ballistica.distance, maxDistance );
ArrayList<Char> chars = new ArrayList<Char>();
for (int i=1; i < Ballistica.distance; i++) {
int c = Ballistica.trace[i];
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();
}
}
private int distance() {
return level() + 4;
}
@Override
protected void fx( int cell, Callback callback ) {
cell = Ballistica.trace[Math.min( Ballistica.distance, distance() ) - 1];
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.";
}
}
@@ -0,0 +1,86 @@
/*
* 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.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.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class WandOfFirebolt extends Wand {
{
name = "Wand of Firebolt";
}
@Override
protected void onZap( int cell ) {
int level = level();
for (int i=1; i < Ballistica.distance - 1; i++) {
int c = Ballistica.trace[i];
if (Level.flamable[c]) {
GameScene.add( Blob.seed( c, 1, Fire.class ) );
}
}
GameScene.add( Blob.seed( cell, 1, Fire.class ) );
Char ch = Actor.findChar( cell );
if (ch != null) {
ch.damage( Random.Int( 1, 8 + level * level ), this );
Buff.affect( ch, Burning.class ).reignite( ch );
ch.sprite.emitter().burst( FlameParticle.FACTORY, 5 );
if (ch == curUser && !ch.isAlive()) {
Dungeon.fail( Utils.format( ResultDescriptions.WAND, name, Dungeon.depth ) );
GLog.n( "You killed yourself with your own Wand of Firebolt..." );
}
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.fire( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"This wand unleashes bursts of magical fire. It will ignite " +
"flammable terrain, and will damage and burn a creature it hits.";
}
}
@@ -0,0 +1,151 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
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.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.SheepSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.watabou.utils.Callback;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class WandOfFlock extends Wand {
{
name = "Wand of Flock";
}
@Override
protected void onZap( int cell ) {
int level = level();
int n = level + 2;
if (Actor.findChar( cell ) != null && Ballistica.distance > 2) {
cell = Ballistica.trace[Ballistica.distance - 2];
}
boolean[] passable = BArray.or( Level.passable, Level.avoid, null );
for (Actor actor : Actor.all()) {
if (actor instanceof Char) {
passable[((Char)actor).pos] = false;
}
}
PathFinder.buildDistanceMap( cell, passable, n );
int dist = 0;
if (Actor.findChar( cell ) != null) {
PathFinder.distance[cell] = Integer.MAX_VALUE;
dist = 1;
}
float lifespan = level + 3;
sheepLabel:
for (int i=0; i < n; i++) {
do {
for (int j=0; j < Level.LENGTH; j++) {
if (PathFinder.distance[j] == dist) {
Sheep sheep = new Sheep();
sheep.lifespan = lifespan;
sheep.pos = j;
GameScene.add( sheep );
Dungeon.level.mobPress( sheep );
CellEmitter.get( j ).burst( Speck.factory( Speck.WOOL ), 4 );
PathFinder.distance[j] = Integer.MAX_VALUE;
continue sheepLabel;
}
}
dist++;
} while (dist < n);
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.wool( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"A flick of this wand summons a flock of magic sheep, creating temporary impenetrable obstacle.";
}
public static class Sheep extends Mob.NPC {
private static final String[] QUOTES = {"Baa!", "Baa?", "Baa.", "Baa..."};
{
name = "sheep";
spriteClass = SheepSprite.class;
}
public float lifespan;
private boolean initialized = false;
@Override
protected boolean act() {
if (initialized) {
HP = 0;
destroy();
sprite.die();
} else {
initialized = true;
spend( lifespan + Random.Float( 2 ) );
}
return true;
}
@Override
public void damage( int dmg, Object src ) {
}
@Override
public String description() {
return
"This is a magic sheep. What's so magical about it? You can't kill it. " +
"It will stand there until it magcially fades away, all the while chewing cud with a blank stare.";
}
@Override
public void interact() {
yell( Random.element( QUOTES ) );
}
}
}
@@ -0,0 +1,118 @@
/*
* 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 java.util.ArrayList;
import java.util.HashSet;
import com.watabou.noosa.Camera;
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.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class WandOfLightning extends Wand {
{
name = "Wand of Lightning";
}
private ArrayList<Char> affected = new ArrayList<Char>();
private int[] points = new int[20];
private int nPoints;
@Override
protected void onZap( int cell ) {
// The actual effect is processed in "fx" method
if (!curUser.isAlive()) {
Dungeon.fail( Utils.format( ResultDescriptions.WAND, name, Dungeon.depth ) );
GLog.n( "You killed yourself with your own Wand of Lightning..." );
}
}
private void hit( Char ch, int damage ) {
if (damage < 1) {
return;
}
if (ch == Dungeon.hero) {
Camera.main.shake( 2, 0.3f );
}
affected.add( ch );
ch.damage( Level.water[ch.pos] && !ch.flying ? (int)(damage * 2) : damage, LightningTrap.LIGHTNING );
ch.sprite.centerEmitter().burst( SparkParticle.FACTORY, 3 );
ch.sprite.flash();
points[nPoints++] = ch.pos;
HashSet<Char> ns = new HashSet<Char>();
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
Char n = Actor.findChar( ch.pos + Level.NEIGHBOURS8[i] );
if (n != null && !affected.contains( n )) {
ns.add( n );
}
}
if (ns.size() > 0) {
hit( Random.element( ns ), Random.Int( damage / 2, damage ) );
}
}
@Override
protected void fx( int cell, Callback callback ) {
nPoints = 0;
points[nPoints++] = Dungeon.hero.pos;
Char ch = Actor.findChar( cell );
if (ch != null) {
affected.clear();
int lvl = level();
hit( ch, Random.Int( 5 + lvl / 2, 10 + lvl ) );
} else {
points[nPoints++] = cell;
CellEmitter.center( cell ).burst( SparkParticle.FACTORY, 3 );
}
curUser.sprite.parent.add( new Lightning( points, nPoints, callback ) );
}
@Override
public String desc() {
return
"This wand conjures forth deadly arcs of electricity, which deal damage " +
"to several creatures standing close to each other.";
}
}
@@ -0,0 +1,153 @@
/*
* 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 java.util.ArrayList;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
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.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.utils.Random;
public class WandOfMagicMissile extends Wand {
public static final String AC_DISENCHANT = "DISENCHANT";
private static final String TXT_SELECT_WAND = "Select a wand to upgrade";
private static final String TXT_DISENCHANTED =
"you disenchanted the Wand of Magic Missile and used its essence to upgrade your %s";
private static final float TIME_TO_DISENCHANT = 2f;
private boolean disenchantEquipped;
{
name = "Wand of Magic Missile";
image = ItemSpriteSheet.WAND_MAGIC_MISSILE;
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (level > 0) {
actions.add( AC_DISENCHANT );
}
return actions;
}
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch != null) {
int level = level();
ch.damage( Random.Int( 1, 6 + level * 2 ), this );
ch.sprite.burst( 0xFF99CCFF, level / 2 + 2 );
if (ch == curUser && !ch.isAlive()) {
Dungeon.fail( Utils.format( ResultDescriptions.WAND, name, Dungeon.depth ) );
GLog.n( "You killed yourself with your own Wand of Magic Missile..." );
}
}
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_DISENCHANT )) {
if (hero.belongings.weapon == this) {
disenchantEquipped = true;
hero.belongings.weapon = null;
updateQuickslot();
} else {
disenchantEquipped = false;
detach( hero.belongings.backpack );
}
curUser = hero;
GameScene.selectItem( itemSelector, WndBag.Mode.WAND, TXT_SELECT_WAND );
} else {
super.execute( hero, action );
}
}
@Override
protected boolean isKnown() {
return true;
}
@Override
public void setKnown() {
}
protected int initialCharges() {
return 3;
}
@Override
public String desc() {
return
"This wand launches missiles of pure magical energy, dealing moderate damage to a target creature.";
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
if (item != null) {
Sample.INSTANCE.play( Assets.SND_EVOKE );
ScrollOfUpgrade.upgrade( curUser );
evoke( curUser );
GLog.w( TXT_DISENCHANTED, item.name() );
item.upgrade();
curUser.spendAndNext( TIME_TO_DISENCHANT );
Badges.validateItemLevelAquired( item );
} else {
if (disenchantEquipped) {
curUser.belongings.weapon = WandOfMagicMissile.this;
WandOfMagicMissile.this.updateQuickslot();
} else {
collect( curUser.belongings.backpack );
}
}
}
};
}
@@ -0,0 +1,63 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
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.Poison;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
public class WandOfPoison extends Wand {
{
name = "Wand of Poison";
}
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch != null) {
Buff.affect( ch, Poison.class ).set( Poison.durationFactor( ch ) * (1 + 2 * (float)Math.pow( 1.5, level() )) );
} else {
GLog.i( "nothing happened" );
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.poison( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"The vile blast of this twisted bit of wood will imbue its target " +
"with a deadly venom. A creature that is poisoned will suffer periodic " +
"damage until the effect ends. The duration of the effect increases " +
"with the level of the staff.";
}
}
@@ -0,0 +1,80 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
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.utils.GLog;
import com.watabou.utils.Callback;
public class WandOfRegrowth extends Wand {
{
name = "Wand of Regrowth";
}
@Override
protected void onZap( int cell ) {
for (int i=1; i < Ballistica.distance-1; i++) {
int p = Ballistica.trace[i];
int c = Dungeon.level.map[p];
if (c == Terrain.EMPTY ||
c == Terrain.EMBERS ||
c == Terrain.EMPTY_DECO) {
Level.set( p, Terrain.GRASS );
}
}
int c = Dungeon.level.map[cell];
if (c == Terrain.EMPTY ||
c == Terrain.EMBERS ||
c == Terrain.EMPTY_DECO ||
c == Terrain.GRASS ||
c == Terrain.HIGH_GRASS) {
GameScene.add( Blob.seed( cell, (level() + 2) * 20, Regrowth.class ) );
} else {
GLog.i( "nothing happened" );
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.foliage( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"\"When life ceases new life always begins to grow... The eternal cycle always remains!\"";
}
}
@@ -0,0 +1,61 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
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.Slow;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
public class WandOfSlowness extends Wand {
{
name = "Wand of Slowness";
}
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch != null) {
Buff.affect( ch, Slow.class, Slow.duration( ch ) / 3 + level() );
} else {
GLog.i( "nothing happened" );
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.slowness( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"This wand will cause a creature to move and attack " +
"at half its ordinary speed until the effect ends";
}
}
@@ -0,0 +1,170 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
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.utils.GLog;
import com.watabou.utils.Callback;
public class WandOfTelekinesis extends Wand {
private static final String TXT_YOU_NOW_HAVE = "You have magically transported %s into your backpack";
{
name = "Wand of Telekinesis";
hitChars = false;
}
@Override
protected void onZap( int cell ) {
boolean mapUpdated = false;
int maxDistance = level() + 4;
Ballistica.distance = Math.min( Ballistica.distance, maxDistance );
Char ch;
Heap heap = null;
for (int i=1; i < Ballistica.distance; i++) {
int c = Ballistica.trace[i];
int before = Dungeon.level.map[c];
if ((ch = Actor.findChar( c )) != null) {
if (i == Ballistica.distance-1) {
ch.damage( maxDistance-1 - i, this );
} else {
int next = Ballistica.trace[i + 1];
if ((Level.passable[next] || Level.avoid[next]) && Actor.findChar( next ) == null) {
Actor.addDelayed( new Pushing( ch, ch.pos, next ), -1 );
ch.pos = next;
Actor.freeCell( next );
// Refactoring needed!
if (ch instanceof Mob) {
Dungeon.level.mobPress( (Mob)ch );
} else {
Dungeon.level.press( ch.pos, ch );
}
} else {
ch.damage( maxDistance-1 - i, this );
}
}
}
if (heap == null && (heap = Dungeon.level.heaps.get( c )) != null) {
switch (heap.type) {
case HEAP:
transport( heap );
break;
case CHEST:
open( heap );
break;
default:
}
}
Dungeon.level.press( c, null );
if (before == Terrain.OPEN_DOOR && Actor.findChar( c ) == null) {
Level.set( c, Terrain.DOOR );
GameScene.updateMap( c );
} else if (Level.water[c]) {
GameScene.ripple( c );
}
if (!mapUpdated && Dungeon.level.map[c] != before) {
mapUpdated = true;
}
}
if (mapUpdated) {
Dungeon.observe();
}
}
private void transport( Heap heap ) {
Item item = heap.pickUp();
if (item.doPickUp( curUser )) {
if (item instanceof Dewdrop) {
} else {
if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade)item).isKnown()) ||
(item instanceof PotionOfStrength && ((PotionOfStrength)item).isKnown())) {
GLog.p( TXT_YOU_NOW_HAVE, item.name() );
} else {
GLog.i( TXT_YOU_NOW_HAVE, item.name() );
}
}
} else {
Dungeon.level.drop( item, curUser.pos ).sprite.drop();
}
}
private void open( Heap heap ) {
heap.type = Type.HEAP;
heap.sprite.link();
heap.sprite.drop();
}
protected void fx( int cell, Callback callback ) {
MagicMissile.force( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"Waves of magic force from this wand will affect all cells on their way triggering traps, trampling high vegetation, " +
"opening closed doors and closing open ones. They also push back monsters.";
}
}
@@ -0,0 +1,88 @@
/*
* 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.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
public class WandOfTeleportation extends Wand {
{
name = "Wand of Teleportation";
}
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch == curUser) {
setKnown();
ScrollOfTeleportation.teleportHero( curUser );
} else if (ch != null) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1) {
GLog.w( ScrollOfTeleportation.TXT_NO_TELEPORT );
} else {
ch.pos = pos;
ch.sprite.place( ch.pos );
ch.sprite.visible = Dungeon.visible[pos];
GLog.i( curUser.name + " teleported " + ch.name + " to somewhere" );
}
} else {
GLog.i( "nothing happened" );
}
}
protected void fx( int cell, Callback callback ) {
MagicMissile.coldLight( curUser.sprite.parent, curUser.pos, cell, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"A blast from this wand will teleport a creature against " +
"its will to a random place on the current level.";
}
}