Search in sources :

Example 6 with Ballistica

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

the class GrimTrap method activate.

@Override
public void activate() {
    Char target = Actor.findChar(pos);
    // find the closest char that can be aimed at
    if (target == null) {
        for (Char ch : Actor.chars()) {
            Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
            if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
                target = ch;
            }
        }
    }
    if (target != null) {
        final Char finalTarget = target;
        final GrimTrap trap = this;
        int damage;
        // almost kill the player
        if (finalTarget == Dungeon.hero && ((float) finalTarget.HP / finalTarget.HT) >= 0.9f) {
            damage = finalTarget.HP - 1;
        // kill 'em
        } else {
            damage = finalTarget.HP;
        }
        final int finalDmg = damage;
        Actor.add(new Actor() {

            {
                // it's a visual effect, gets priority no matter what
                actPriority = VFX_PRIO;
            }

            @Override
            protected boolean act() {
                final Actor toRemove = this;
                ((MagicMissile) finalTarget.sprite.parent.recycle(MagicMissile.class)).reset(MagicMissile.SHADOW, DungeonTilemap.tileCenterToWorld(pos), finalTarget.sprite.center(), new Callback() {

                    @Override
                    public void call() {
                        finalTarget.damage(finalDmg, trap);
                        if (finalTarget == Dungeon.hero) {
                            Sample.INSTANCE.play(Assets.SND_CURSED);
                            if (!finalTarget.isAlive()) {
                                Dungeon.fail(GrimTrap.class);
                                GLog.n(Messages.get(GrimTrap.class, "ondeath"));
                            }
                        } else {
                            Sample.INSTANCE.play(Assets.SND_BURNING);
                        }
                        finalTarget.sprite.emitter().burst(ShadowParticle.UP, 10);
                        Actor.remove(toRemove);
                        next();
                    }
                });
                return false;
            }
        });
    } else {
        CellEmitter.get(pos).burst(ShadowParticle.UP, 10);
        Sample.INSTANCE.play(Assets.SND_BURNING);
    }
}
Also used : Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Actor(com.shatteredpixel.shatteredpixeldungeon.actors.Actor) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)

Example 7 with Ballistica

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

the class WornDartTrap method activate.

@Override
public void activate() {
    Char target = Actor.findChar(pos);
    // find the closest char that can be aimed at
    if (target == null) {
        for (Char ch : Actor.chars()) {
            Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
            if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
                target = ch;
            }
        }
    }
    if (target != null) {
        final Char finalTarget = target;
        final WornDartTrap trap = this;
        if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
            Actor.add(new Actor() {

                {
                    // it's a visual effect, gets priority no matter what
                    actPriority = VFX_PRIO;
                }

                @Override
                protected boolean act() {
                    final Actor toRemove = this;
                    ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)).reset(pos, finalTarget.sprite, new Dart(), new Callback() {

                        @Override
                        public void call() {
                            int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
                            finalTarget.damage(dmg, trap);
                            if (finalTarget == Dungeon.hero && !finalTarget.isAlive()) {
                                Dungeon.fail(trap.getClass());
                            }
                            Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
                            finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
                            finalTarget.sprite.flash();
                            Actor.remove(toRemove);
                            next();
                        }
                    });
                    return false;
                }
            });
        } else {
            finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
        }
    }
}
Also used : Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Actor(com.shatteredpixel.shatteredpixeldungeon.actors.Actor) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) Dart(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)

Example 8 with Ballistica

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

the class PoisonDartTrap method activate.

@Override
public void activate() {
    Char target = Actor.findChar(pos);
    // find the closest char that can be aimed at
    if (target == null) {
        for (Char ch : Actor.chars()) {
            Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
            if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
                target = ch;
            }
        }
    }
    if (target != null) {
        final Char finalTarget = target;
        final PoisonDartTrap trap = this;
        if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
            Actor.add(new Actor() {

                {
                    // it's a visual effect, gets priority no matter what
                    actPriority = VFX_PRIO;
                }

                @Override
                protected boolean act() {
                    final Actor toRemove = this;
                    ((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)).reset(pos, finalTarget.sprite, new PoisonDart(), new Callback() {

                        @Override
                        public void call() {
                            int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
                            finalTarget.damage(dmg, trap);
                            if (finalTarget == Dungeon.hero && !finalTarget.isAlive()) {
                                Dungeon.fail(trap.getClass());
                            }
                            Buff.affect(finalTarget, Poison.class).set(4 + Dungeon.depth);
                            Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
                            finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
                            finalTarget.sprite.flash();
                            Actor.remove(toRemove);
                            next();
                        }
                    });
                    return false;
                }
            });
        } else {
            finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
            Buff.affect(finalTarget, Poison.class).set(4 + Dungeon.depth);
        }
    }
}
Also used : Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Actor(com.shatteredpixel.shatteredpixeldungeon.actors.Actor) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) PoisonDart(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.PoisonDart) Poison(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison)

Example 9 with Ballistica

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

the class Repulsion method proc.

@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
    int level = Math.max(0, armor.level());
    if (Random.Int(level + 5) >= 4) {
        int oppositeHero = attacker.pos + (attacker.pos - defender.pos);
        Ballistica trajectory = new Ballistica(attacker.pos, oppositeHero, Ballistica.MAGIC_BOLT);
        WandOfBlastWave.throwChar(attacker, trajectory, 2);
    }
    return damage;
}
Also used : Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)

Example 10 with Ballistica

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

the class Guard method chain.

private boolean chain(int target) {
    if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))
        return false;
    Ballistica chain = new Ballistica(pos, target, Ballistica.PROJECTILE);
    if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || Dungeon.level.pit[chain.path.get(1)])
        return false;
    else {
        int newPos = -1;
        for (int i : chain.subPath(1, chain.dist)) {
            if (!Dungeon.level.solid[i] && Actor.findChar(i) == null) {
                newPos = i;
                break;
            }
        }
        if (newPos == -1) {
            return false;
        } else {
            final int newPosFinal = newPos;
            this.target = newPos;
            yell(Messages.get(this, "scorpion"));
            sprite.parent.add(new Chains(sprite.center(), enemy.sprite.center(), new Callback() {

                public void call() {
                    Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback() {

                        public void call() {
                            enemy.pos = newPosFinal;
                            Dungeon.level.press(newPosFinal, enemy, true);
                            Cripple.prolong(enemy, Cripple.class, 4f);
                            if (enemy == Dungeon.hero) {
                                Dungeon.hero.interrupt();
                                Dungeon.observe();
                                GameScene.updateFog();
                            }
                        }
                    }), -1);
                    next();
                }
            }));
        }
    }
    chainsUsed = true;
    return true;
}
Also used : Callback(com.watabou.utils.Callback) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) Chains(com.shatteredpixel.shatteredpixeldungeon.effects.Chains)

Aggregations

Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)11 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)5 Callback (com.watabou.utils.Callback)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Poison (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison)1 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)1 Beam (com.shatteredpixel.shatteredpixeldungeon.effects.Beam)1 Chains (com.shatteredpixel.shatteredpixeldungeon.effects.Chains)1 Pushing (com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 Bag (com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag)1 Dart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)1 PoisonDart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.PoisonDart)1 ArrayList (java.util.ArrayList)1