Search in sources :

Example 1 with ShockingTrap

use of com.shatteredpixel.shatteredpixeldungeon.levels.traps.ShockingTrap in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CursedWand method uncommonEffect.

private static void uncommonEffect(final Wand wand, final Hero user, final Ballistica bolt) {
    switch(Random.Int(4)) {
        // Random plant
        case 0:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    int pos = bolt.collisionPos;
                    // place the plant infront of an enemy so they walk into it.
                    if (Actor.findChar(pos) != null && bolt.dist > 1) {
                        pos = bolt.path.get(bolt.dist - 1);
                    }
                    if (pos == Terrain.EMPTY || pos == Terrain.EMBERS || pos == Terrain.EMPTY_DECO || pos == Terrain.GRASS || pos == Terrain.HIGH_GRASS) {
                        Dungeon.level.plant((Plant.Seed) Generator.random(Generator.Category.SEED), pos);
                    }
                    wand.wandUsed();
                }
            });
            break;
        // Health transfer
        case 1:
            final Char target = Actor.findChar(bolt.collisionPos);
            if (target != null) {
                cursedFX(user, bolt, new Callback() {

                    public void call() {
                        int damage = user.lvl * 2;
                        switch(Random.Int(2)) {
                            case 0:
                                user.HP = Math.min(user.HT, user.HP + damage);
                                user.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3);
                                target.damage(damage, wand);
                                target.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10);
                                break;
                            case 1:
                                user.damage(damage, this);
                                user.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10);
                                target.HP = Math.min(target.HT, target.HP + damage);
                                target.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3);
                                Sample.INSTANCE.play(Assets.SND_CURSED);
                                if (!user.isAlive()) {
                                    Dungeon.fail(wand.getClass());
                                    GLog.n(Messages.get(CursedWand.class, "ondeath", wand.name()));
                                }
                                break;
                        }
                        wand.wandUsed();
                    }
                });
            } else {
                GLog.i(Messages.get(CursedWand.class, "nothing"));
                wand.wandUsed();
            }
            break;
        // Bomb explosion
        case 2:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    new Bomb().explode(bolt.collisionPos);
                    wand.wandUsed();
                }
            });
            break;
        // shock and recharge
        case 3:
            new ShockingTrap().set(user.pos).activate();
            Buff.prolong(user, Recharging.class, 20f);
            ScrollOfRecharging.charge(user);
            SpellSprite.show(user, SpellSprite.CHARGE);
            wand.wandUsed();
            break;
    }
}
Also used : Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) ShockingTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.ShockingTrap) Bomb(com.shatteredpixel.shatteredpixeldungeon.items.Bomb)

Aggregations

Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Bomb (com.shatteredpixel.shatteredpixeldungeon.items.Bomb)1 ShockingTrap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.ShockingTrap)1 Callback (com.watabou.utils.Callback)1