Search in sources :

Example 41 with Char

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Plant method trigger.

public void trigger() {
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ((Hero) ch).interrupt();
        if (((Hero) ch).subClass == HeroSubClass.WARDEN) {
            Buff.affect(ch, Barkskin.class).level(ch.HT / 3);
        }
    }
    wither();
    activate();
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Barkskin(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin)

Example 42 with Char

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.

the class FlashingTrap method activate.

@Override
public void activate() {
    Char c = Actor.findChar(pos);
    if (c != null) {
        int damage = Math.max(0, (4 + Dungeon.depth) - c.drRoll());
        Buff.affect(c, Bleeding.class).set(damage);
        Buff.prolong(c, Blindness.class, 10f);
        Buff.prolong(c, Cripple.class, 20f);
        if (c instanceof Mob) {
            if (((Mob) c).state == ((Mob) c).HUNTING)
                ((Mob) c).state = ((Mob) c).WANDERING;
            ((Mob) c).beckon(Dungeon.level.randomDestination());
        }
    }
    if (Dungeon.level.heroFOV[pos]) {
        GameScene.flash(0xFFFFFF);
        Sample.INSTANCE.play(Assets.SND_BLAST);
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Bleeding(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)

Example 43 with Char

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char 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)

Example 44 with Char

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CursedWand method commonEffect.

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

                public void call() {
                    Char target = Actor.findChar(bolt.collisionPos);
                    switch(Random.Int(2)) {
                        case 0:
                            if (target != null)
                                Buff.affect(target, Burning.class).reignite(target);
                            Buff.affect(user, Frost.class, Frost.duration(user) * Random.Float(3f, 5f));
                            break;
                        case 1:
                            Buff.affect(user, Burning.class).reignite(user);
                            if (target != null)
                                Buff.affect(target, Frost.class, Frost.duration(target) * Random.Float(3f, 5f));
                            break;
                    }
                    wand.wandUsed();
                }
            });
            break;
        // spawns some regrowth
        case 1:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    int c = Dungeon.level.map[bolt.collisionPos];
                    if (c == Terrain.EMPTY || c == Terrain.EMBERS || c == Terrain.EMPTY_DECO || c == Terrain.GRASS || c == Terrain.HIGH_GRASS) {
                        GameScene.add(Blob.seed(bolt.collisionPos, 30, Regrowth.class));
                    }
                    wand.wandUsed();
                }
            });
            break;
        // random teleportation
        case 2:
            switch(Random.Int(2)) {
                case 0:
                    ScrollOfTeleportation.teleportHero(user);
                    wand.wandUsed();
                    break;
                case 1:
                    cursedFX(user, bolt, new Callback() {

                        public void call() {
                            Char ch = Actor.findChar(bolt.collisionPos);
                            if (ch == user) {
                                ScrollOfTeleportation.teleportHero(user);
                                wand.wandUsed();
                            } else if (ch != null && !ch.properties().contains(Char.Property.IMMOVABLE)) {
                                int count = 10;
                                int pos;
                                do {
                                    pos = Dungeon.level.randomRespawnCell();
                                    if (count-- <= 0) {
                                        break;
                                    }
                                } while (pos == -1);
                                if (pos == -1 || Dungeon.bossLevel()) {
                                    GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
                                } else {
                                    ch.pos = pos;
                                    if (((Mob) ch).state == ((Mob) ch).HUNTING)
                                        ((Mob) ch).state = ((Mob) ch).WANDERING;
                                    ch.sprite.place(ch.pos);
                                    ch.sprite.visible = Dungeon.level.heroFOV[pos];
                                }
                            }
                            wand.wandUsed();
                        }
                    });
                    break;
            }
            break;
        // random gas at location
        case 3:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    switch(Random.Int(3)) {
                        case 0:
                            GameScene.add(Blob.seed(bolt.collisionPos, 800, ConfusionGas.class));
                            break;
                        case 1:
                            GameScene.add(Blob.seed(bolt.collisionPos, 500, ToxicGas.class));
                            break;
                        case 2:
                            GameScene.add(Blob.seed(bolt.collisionPos, 200, ParalyticGas.class));
                            break;
                    }
                    wand.wandUsed();
                }
            });
            break;
    }
}
Also used : ScrollOfTeleportation(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Frost(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost) Burning(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)

Example 45 with Char

use of com.shatteredpixel.shatteredpixeldungeon.actors.Char in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CursedWand method rareEffect.

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

                public void call() {
                    Char ch = Actor.findChar(bolt.collisionPos);
                    if (ch != null && ch != user && !ch.properties().contains(Char.Property.BOSS) && !ch.properties().contains(Char.Property.MINIBOSS)) {
                        Sheep sheep = new Sheep();
                        sheep.lifespan = 10;
                        sheep.pos = ch.pos;
                        ch.destroy();
                        ch.sprite.killAndErase();
                        Dungeon.level.mobs.remove(ch);
                        TargetHealthIndicator.instance.target(null);
                        GameScene.add(sheep);
                        CellEmitter.get(sheep.pos).burst(Speck.factory(Speck.WOOL), 4);
                    } else {
                        GLog.i(Messages.get(CursedWand.class, "nothing"));
                    }
                    wand.wandUsed();
                }
            });
            break;
        // curses!
        case 1:
            CursingTrap.curse(user);
            wand.wandUsed();
            break;
        // inter-level teleportation
        case 2:
            if (Dungeon.depth > 1 && !Dungeon.bossLevel()) {
                // each depth has 1 more weight than the previous depth.
                float[] depths = new float[Dungeon.depth - 1];
                for (int i = 1; i < Dungeon.depth; i++) depths[i - 1] = i;
                int depth = 1 + Random.chances(depths);
                Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
                if (buff != null)
                    buff.detach();
                InterlevelScene.mode = InterlevelScene.Mode.RETURN;
                InterlevelScene.returnDepth = depth;
                InterlevelScene.returnPos = -1;
                Game.switchScene(InterlevelScene.class);
            } else {
                ScrollOfTeleportation.teleportHero(user);
                wand.wandUsed();
            }
            break;
        // summon monsters
        case 3:
            new SummoningTrap().set(user.pos).activate();
            wand.wandUsed();
            break;
    }
}
Also used : Callback(com.watabou.utils.Callback) TimekeepersHourglass(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Sheep(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Sheep) SummoningTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Aggregations

Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)65 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)13 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)8 Callback (com.watabou.utils.Callback)8 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)5 ArrayList (java.util.ArrayList)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)3 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)3 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)3 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)3 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Paralysis (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis)2 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)2 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 CorrosiveGas (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1