Search in sources :

Example 1 with Ballistica

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

the class WandOfBlastWave method onHit.

@Override
public // behaves just like glyph of Repulsion
void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
    int level = Math.max(0, staff.level());
    // lvl 2 - 50%
    if (Random.Int(level + 4) >= 3) {
        int oppositeHero = defender.pos + (defender.pos - attacker.pos);
        Ballistica trajectory = new Ballistica(defender.pos, oppositeHero, Ballistica.MAGIC_BOLT);
        throwChar(defender, trajectory, 2);
    }
}
Also used : Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)

Example 2 with Ballistica

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

the class WandOfBlastWave method onZap.

@Override
protected void onZap(Ballistica bolt) {
    Sample.INSTANCE.play(Assets.SND_BLAST);
    BlastWave.blast(bolt.collisionPos);
    int damage = damageRoll();
    // presses all tiles in the AOE first
    for (int i : PathFinder.NEIGHBOURS9) {
        Dungeon.level.press(bolt.collisionPos + i, Actor.findChar(bolt.collisionPos + i), true);
    }
    // throws other chars around the center.
    for (int i : PathFinder.NEIGHBOURS8) {
        Char ch = Actor.findChar(bolt.collisionPos + i);
        if (ch != null) {
            processSoulMark(ch, chargesPerCast());
            ch.damage(Math.round(damage * 0.667f), this);
            if (ch.isAlive()) {
                Ballistica trajectory = new Ballistica(ch.pos, ch.pos + i, Ballistica.MAGIC_BOLT);
                int strength = 1 + Math.round(level() / 2f);
                throwChar(ch, trajectory, strength);
            }
        }
    }
    // throws the char at the center of the blast
    Char ch = Actor.findChar(bolt.collisionPos);
    if (ch != null) {
        processSoulMark(ch, chargesPerCast());
        ch.damage(damage, this);
        if (ch.isAlive() && bolt.path.size() > bolt.dist + 1) {
            Ballistica trajectory = new Ballistica(ch.pos, bolt.path.get(bolt.dist + 1), Ballistica.MAGIC_BOLT);
            int strength = level() + 3;
            throwChar(ch, trajectory, strength);
        }
    }
    if (!curUser.isAlive()) {
        Dungeon.fail(getClass());
        GLog.n(Messages.get(this, "ondeath"));
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)

Example 3 with Ballistica

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

the class Succubus method blink.

private void blink(int target) {
    Ballistica route = new Ballistica(pos, target, Ballistica.PROJECTILE);
    int cell = route.collisionPos;
    // can't occupy the same cell as another char, so move back one.
    if (Actor.findChar(cell) != null && cell != this.pos)
        cell = route.path.get(route.dist - 1);
    if (Dungeon.level.avoid[cell]) {
        ArrayList<Integer> candidates = new ArrayList<>();
        for (int n : PathFinder.NEIGHBOURS8) {
            cell = route.collisionPos + n;
            if (Dungeon.level.passable[cell] && Actor.findChar(cell) == null) {
                candidates.add(cell);
            }
        }
        if (candidates.size() > 0)
            cell = Random.element(candidates);
        else {
            delay = BLINK_DELAY;
            return;
        }
    }
    ScrollOfTeleportation.appear(this, cell);
    delay = BLINK_DELAY;
}
Also used : Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) ArrayList(java.util.ArrayList)

Example 4 with Ballistica

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

the class Eye method canAttack.

@Override
protected boolean canAttack(Char enemy) {
    if (beamCooldown == 0) {
        Ballistica aim = new Ballistica(pos, enemy.pos, Ballistica.STOP_TERRAIN);
        if (enemy.invisible == 0 && !isCharmedBy(enemy) && fieldOfView[enemy.pos] && aim.subPath(1, aim.dist).contains(enemy.pos)) {
            beam = aim;
            beamTarget = aim.collisionPos;
            return true;
        } else
            // if the beam is charged, it has to attack, will aim at previous location of target.
            return beamCharged;
    } else
        return super.canAttack(enemy);
}
Also used : Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)

Example 5 with Ballistica

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

the class DisintegrationTrap 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;
            }
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null)
        heap.explode();
    if (target != null) {
        if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
            Sample.INSTANCE.play(Assets.SND_RAY);
            ShatteredPixelDungeon.scene().add(new Beam.DeathRay(DungeonTilemap.tileCenterToWorld(pos), target.sprite.center()));
        }
        target.damage(Math.max(target.HT / 5, Random.Int(target.HP / 2, 2 * target.HP / 3)), this);
        if (target == Dungeon.hero) {
            Hero hero = (Hero) target;
            if (!hero.isAlive()) {
                Dungeon.fail(getClass());
                GLog.n(Messages.get(this, "ondeath"));
            } else {
                Item item = hero.belongings.randomUnequipped();
                Bag bag = hero.belongings.backpack;
                // bags do not protect against this trap
                if (item instanceof Bag) {
                    bag = (Bag) item;
                    item = Random.element(bag.items);
                }
                if (item == null || item.level() > 0 || item.unique)
                    return;
                if (!item.stackable) {
                    item.detachAll(bag);
                    GLog.w(Messages.get(this, "one", item.name()));
                } else {
                    int n = Random.NormalIntRange(1, (item.quantity() + 1) / 2);
                    for (int i = 1; i <= n; i++) item.detach(bag);
                    GLog.w(Messages.get(this, "some", item.name()));
                }
            }
        }
    }
}
Also used : Beam(com.shatteredpixel.shatteredpixeldungeon.effects.Beam) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Bag(com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

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